<?php

namespace DebugComponent\Plugin;

class Settings implements \DebugComponent\IPlugin, \DebugComponent\IRenderable {

    public function __construct() {
        $this->settings = array();
    }

    public function add($key, $value, $group) {
        if (!isset($this->settings[$group])) {
            $this->settings[$group] = array();
        }
        $this->settings[$group][$key] = $value;
    }

    public function setRenderer(\DebugComponent\IRenderer $renderer) {
        $this->renderer = $renderer;
    }

    public function getTitle() {
        return 'Settings';
    }

    public function getSubtitle() {
        return null;
    }

    public function render() {
        $data = new \DebugComponent\ParameterHolder();
        $data->set('settings', $this->settings);
        $data->set('title', $this->getTitle());
        $data->set('subtitle', $this->getSubtitle());
        return $this->renderer->render($data);
    }

    private $renderer;
    private $settings;
}